<?php
declare(strict_types = 1);

namespace app\common\model\delivery;

use app\common\model\base\BaseModel;
use app\common\model\User;
use think\facade\Cache;

class Driver Extends BaseModel
{
    public function user()
    {
        return $this->hasOne(User::class,'id','user_id')->field('id,avatar,nickname');
    }

    public function channel()
    {
        return $this->hasOne(Channel::class,'id','channel_id');
    }

    public static function getGirdIds($drivers,$user_id)
    {
        $driverids=[];
        foreach ($drivers as $value){
            $driverids[]=$value['id'];
        }
        $girdids=[];
        foreach ($driverids as $driverid){
            $girdids=array_merge($girdids,ChannelGird::where("FIND_IN_SET({$driverid},drivers)")->column('id'));
        }
        return $girdids;
    }
}